﻿using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using  MDB;
using mtfNet;
using Public;
using Project;

namespace Project
{
    public class ProjectDataBase
    {
        string m_ConfigDbPath;
        string m_DataDbPath;
        public MySqlite ConfigDb { get; set; }
        public MySqlite DataDb { get; set; }

        public ProjectDataBase()
        {
            m_ConfigDbPath = mtf.GetmtfInstance().CreateInnerFolder(0, "DataFile/" + global.gProjectFolder + "/File/Database")/* + "/ConfigDB.db"*/;
            m_DataDbPath = mtf.GetmtfInstance().CreateExteriorFolder("D:/Data/" + global.gProjectFolder + "Data/DataBase")/* + "/DataDB.db"*/;

            ConfigDb = new MySqlite(m_ConfigDbPath, "ConfigDB.db");
            DataDb = new MySqlite(m_DataDbPath, "DataDB.db");


            CreateTable();



        }

        void CreateTable()
        {
            string sql;
            sql = "CREATE TABLE IF NOT EXISTS 取料位标定参数("
            +"吸嘴位置 TEXT PRIMARY KEY  NOT NULL,"
            +"吸头X           REAL    NOT NULL,"
            +"吸头Y           REAL    NOT NULL,"
            +"吸头R           REAL    NOT NULL,"
            +"相机X           REAL    NOT NULL,"
            +"相机Y           REAL    NOT NULL,"
            +"相机R           REAL    NOT NULL,"
            +"OffsetX         REAL    NOT NULL,"
            +"OffsetY         REAL    NOT NULL,"
            +"OffsetR         REAL    NOT NULL," 
            + "备注           TEXT)";
            DataDb.CreateTable(sql);

            sql = "CREATE TABLE IF NOT EXISTS 成员变量表("
            + "序号     INTEGER   PRIMARY KEY  NOT NULL,"
            + "变量名  TEXT,"
            +"int        INTEGER,"
            +"double     REAL,"
            + "string    TEXT,"
            + "备注    TEXT)";
            ConfigDb.CreateTable(sql);

        }





















    }
}
